package org.speed.spring.core.aop;

import org.speed.spring.core.aop.cglb.CglibProxy;
import org.springframework.aop.framework.ProxyFactoryBean;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class App {

	public static void main(String[] args) {
		
		//proxy();
		
		String location = "spring-bean.xml";
    	ClassPathXmlApplicationContext aContext = new ClassPathXmlApplicationContext();
    	aContext.setConfigLocation(location);
    	aContext.refresh();
    	
    	
    	UserService proxyFactoryBean = aContext.getBean("proxyFactoryBean", UserService.class);
    	proxyFactoryBean.doPay("1", 1);
	}

	private static void proxy() {
		//UserService target = new UserServiceImpl();
		//JdkProxy<UserService> jdkProxy = new JdkProxy<UserService>(target);
		//String rs = jdkProxy.getProxy().doPay("1", 11);
		//System.out.println(rs);
		
		
		//CglibProxy<UserService> cglibProxy = new CglibProxy<UserService>(target);
		//rs = cglibProxy.getProxy().doPay("1", 11);
		//System.out.println(rs);

		
		OrderService orderService = new OrderService();
		CglibProxy<OrderService> cglibProxy = new CglibProxy<OrderService>(orderService);
		String rs = cglibProxy.getProxy().exec("1");
		System.out.println(rs);
	}

}
